<template>
    <div id="tab">
        <ul>
            <li v-for="(item, i) in tabs" :key="i" :class="current === i ? 'active' : ''" @click="tabClick(i, item)">
                {{item.name}}
            </li>
        </ul>
    </div>
</template>

<script>
export default {
    name: 'tab',
    props: {
        tabs: Array
    },
    data() { 
        return {
            current: 0
        }
    },
    created() {

    },
    methods:{
        tabClick(i, item) {
            this.current = i
            this.$router.push({
                path: item.url
            })
        }
    },
}
</script>

<style scoped lang="scss">
#tab{
    width: 100%;
    height: 1rem;
    ul{
        height: 100%;
        display: flex;
        li {
            flex: 1;
            text-align: center;
            line-height: 1rem;
            font-size: .24rem;
        }
        .active{
            color: red;
        }
    }
}
</style>